set scheme s2color

use "$project_path/data/4_regdata/regdata", clear

** Figure 3(a)
rddensity runvar
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar, plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(medlarge)) xlabel(, labsize(medlarge)) ylabel(, labsize(medlarge)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medium)))
graph export "$project_path/output/figures/Figure_3a.pdf", as(pdf) name("Graph") replace

** Figure 3(b)
rddensity runvar if Type_Election=="Presidential"
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if Type_Election=="Presidential", plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/figures/Figure_3b.pdf", as(pdf) name("Graph") replace

** Figure 3(c)
rddensity runvar if Type_Election=="Parliamentary"
local mccrary_pval : di %8.3f e(pv_q)
rddensity runvar if Type_Election=="Parliamentary", plot plot_range(-100 100) hist_n(50 50) hist_range(-100 100) graph_opt(xtitle("Margin of victory of the challenger", size(large)) xlabel(, labsize(large)) ylabel(, labsize(large)) legend(off) graphregion(color(white)) note("p-value: `mccrary_pval'", size(medlarge)))
graph export "$project_path/output/figures/Figure_3c.pdf", as(pdf) name("Graph") replace

